var express = require('express')
var path = require('path')

var indexRouter = require('./routes/index')

var app = express()

// 导入CORS 模块
const cors = require('cors')
app.use(cors())

app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(express.static(path.join(__dirname, 'public')))

app.use((req, res, next) => {
  try {
    next()
  } catch (e) {
    console.log(e)
  }
})

app.use('/', indexRouter)

app.listen('8888', function () {
  console.log('http://127.0.0.1:8888')
})
